﻿@model PhoneBilling.Models.PaymentModel
@{
    ViewBag.Title = "收款";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.async.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.edit.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.treeview.sortable.js")"></script>
<link href="@Url.Content("~/Content/js/jquery.treeview.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    function check(id) {
        var checked = $("#" + id).attr("checked");
        if (checked == "checked") {
            $(".all").removeAttr("checked");
            $("." + id).attr("checked", checked);
        }
        else {
            $("." + id).removeAttr("checked");
        }
    }
    function beforeSubmit()
    {
        var str = "";
        $(".extension").each(function()
        {
            if($(this).attr("checked") == "checked")
            {
                if(str == "")
                    str += $(this).attr("id");
                else
                    str += "!" + $(this).attr("id");
            }
        });
        $("#SelectItem").attr("value" , str);
    }
     $(document).ready(function () {
         $("#tree").treeview();
     });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnConfirm").ligerButton(
        {
            click: function () {
                beforeSubmit();
                $('form').submit();
            }
        });
    });
    
</script>
@using (Html.BeginForm())
{ 
    @Html.HiddenFor(m => m.SelectItem, new { id = "SelectItem" });
    <div>
        <h3 class="tlt">请选择部门、分组或者分机</h3>
        <ul id="tree" class="treeview-gray">
     @{foreach (var department in Model.DepartmentList)
     {
        <li class="closed"><input type=checkbox id="@department.ID" class="all @department.ID" onclick="check('@department.ID')"/><span class="folder">@department.名称</span> 
        @if(department.分组List.Count >0)
        {
        <ul>
            @{foreach (var group1 in department.分组List)
              {
                <li class="closed"><input type=checkbox id="@group1.ID" class="all @department.ID @group1.ID" onclick="check('@group1.ID')"/><span class="folder">@group1.名称</span> 
                            
                @if (group1.分组List.Count > 0)
                {
                <ul>
                    @{foreach (var group2 in group1.分组List)
                      {
                        <li class="closed"><input type=checkbox id="@group2.ID" class="all @department.ID @group1.ID @group2.ID" onclick="check('@group2.ID')"/><span class="folder">@group2.名称</span> 
                
                        @if (group2.分组List.Count > 0)
                        {
                        <ul>
                            @{foreach (var group3 in group2.分组List)
                              {
                                <li><input type=checkbox id="@group3.ID" class="all @department.ID @group1.ID @group2.ID @group3.ID" onclick="check('@group3.ID')"/><span class="folder">@group3.名称</span> 
                                @if (group3.ExtensionList.Count > 0)
                                {
                                <ul>
                                    @{foreach (var extension in group3.ExtensionList)
                                      {
                                        <li><input type=checkbox id="@extension.分机号码" class="all @department.ID @group1.ID @group2.ID @group3.ID extension"/><span class="folder">分机：@extension.分机号码</span> 
                                        </li>
                                      }}
                                </ul>
                                }
                                </li>
                              }}
                        </ul>
                        }
                        @if (group2.ExtensionList.Count > 0)
                        {
                        <ul>
                            @{foreach (var extension in group2.ExtensionList)
                              {
                               <li><input type=checkbox id="@extension.分机号码" class="all @department.ID @group1.ID @group2.ID extension"/><span class="folder">分机：@extension.分机号码</span> 
                               </li>
                              }}
                        </ul>
                        }
                        </li>
                      }}
                </ul>
                }
                @if (group1.ExtensionList.Count > 0)
                {
                <ul>
                    @{foreach (var extension in group1.ExtensionList)
                      {
                        <li><input type=checkbox id="all @extension.分机号码" class="all @department.ID @group1.ID extension"/><span class="folder">分机：@extension.分机号码 @extension.用户名</span> 
                        </li>
                      }}
                </ul>
                }
                </li>
              }}
        </ul>
        }
        
        </li>
     }}
     </ul>
     <p class="submit">
        <input type="button" id="btnConfirm" value="确定" />
        @*<input type="submit" value="确定" class="input-submit" onclick="beforeSubmit()" />*@
     </p>
    </div>
}